package com.oamicnet.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.oamicnet.entity.Student;
import com.oamicnet.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("studentService")
@Transactional
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public List<Student> findAll() {
        return studentMapper.selectList(null);
    }

    @Override
    public void save(Student student) {
        studentMapper.insert(student);
    }

    @Override
    public void delete(Integer id) {
        studentMapper.deleteById(id);
    }

    @Override
    public void update(Student student) {
        studentMapper.updateById(student);
    }

    @Override
    public Student findById(Integer id) {
        return studentMapper.selectOne(new QueryWrapper<Student>().eq("id",id));
//        return studentMapper.selectById(id);
    }
}
